package com.anytron.test;

import cn.hutool.crypto.Mode;
import cn.hutool.crypto.Padding;
import cn.hutool.crypto.symmetric.DES;

public class Demo {

	public static void main(String[] args) {

		doit();
	}

	public static void doit() {
		String text = "HelloWorld";
        // key：DES模式下，key必须为8位
        String key = "W1E2R3T4";
        DES des = new DES(Mode.ECB, Padding.PKCS5Padding, key.getBytes());
     // DES des = new DES(Mode.CBC, Padding.PKCS5Padding, key.getBytes(), iv.getBytes());
 
        String encrypt = des.encryptBase64(text);
        System.out.println(encrypt);
 
        String decrypt = des.decryptStr(encrypt);
        System.out.println(decrypt);
	}

}
